import axios from 'axios'
import * as types from '../actionTypes/articleList'

// thunk action
export const getArticles = channelId => {
  return async dispatch => {
    const res = await axios.get(
      `http://geek.itheima.net/v1_0/articles?channel_id=${channelId}&timestamp=${Date.now()}`
    )
    // res.data.data.results 文章列表数据
    dispatch({ type: types.GET_ARTICLES, payload: res.data.data.results })
  }
}